package genetic.treenodes;

import genetic.Arity;
import genetic.GPTreeNode;
import genetic.DataSet;

public class Variable extends GPTreeNode implements Cloneable {

	String name;
	
	public Variable(String name) {
		this.name = name;
	}
	
	@Override
	public double getValue(DataSet ds) {
		return ds.get(name);
	}

	@Override
	public Arity getArity() {
		return Arity.zero;
	}

	public Variable clone() {
		Variable clone = (Variable)super.clone();
		clone.name = this.name;
		return clone;
	}

	/* (non-Javadoc)
	 * @see javax.swing.tree.TreeNode#getAllowsChildren()
	 */
	@Override
	public boolean getAllowsChildren() {
		return false;
	}

	/* (non-Javadoc)
	 * @see javax.swing.tree.TreeNode#isLeaf()
	 */
	@Override
	public boolean isLeaf() {
		return true;
	}
	
}
